package com.tuling.spring;

import org.aopalliance.intercept.MethodInterceptor;
import org.springframework.aop.framework.ProxyFactory;

/**
 * MethodInterceptor Demo
 */
public class ProxyFactoryDemoB {

	public static void main(String[] args) {
		ProxyFactory proxyFactory = new ProxyFactory(new CommonClass());
		proxyFactory.addAdvice((MethodInterceptor) invocation -> {
			System.out.println("doing A before...");
			Object obj = invocation.proceed();
			System.out.println("doing A after...");
			return obj;
		});
		CommonClass commonClass = (CommonClass) proxyFactory.getProxy();
		commonClass.say();
	}
}
